<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>{:session('cp.cpsysname')}--系统管理平台</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
        <meta name="description" content="{:config('webconfig.description');}">
        <meta name="keywords" content="{:config('webconfig.keywords');}">
        <meta name="author" content="runoob">

        <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
        <link rel="stylesheet" href="__STATIC_URL__/static/css/addmchat.css" />
        <script src="__STATIC_URL__/static/js/jquery-2.1.4.min.js"></script>
        <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>
    {include file='public/header'/}
    <section>
        <!------------------导航-------------------------->
        {include file='public/left'/}
        <!--------------------------主要内容区域------------------------------------->
        <div class="content">
            <div class="page-heading mgl15 mgr15">
                <ul class="breadcrumb">
                    <li>当前位置是&nbsp;:&nbsp;</li>
                    <li><a href="#">代理商管理</a></li>
                    <li class="active" style="color: #02b87f;"> 代理商列表</li>
                </ul>
            </div>
            <div class="panel mgl15 mgr15" style="position: relative;">
                <div class="panel-heading addCharts" style="background:#ededed;">代理商列表</div>
                <div class="text-right" style="position: absolute;right: 20px;top: 4px;">
                    <a href="{:url('Agents/agentadd')}" style="display: inline;"><button  class="btn btn-info">添加代理商</button></a>
                </div>
                <div class="panel-body">
                <table class="table table-hover table-bordered">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>服务商名称</th>
                            <th>登入账号</th>

                            <th>手机</th>
                            <th>地址</th>

                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    {volist name="agentlist" id="vo"}
                        <tr class="">
                            <td>{$vo['id']}</td>
                            <td>{$vo['name']}</td>

                            <td>{$vo['LoginUsers']['username']}</td>
                            <td>{$vo['tel']}</td>
                            <td>{$vo['address']}</td>
                            <td>
                                <a href="{:url('agents/agentinfo',['id'=>$vo['id']])}" class="btn-link">查看</a>&nbsp;&nbsp;|&nbsp;
                                <a href="{:url('agents/agentxg',['id'=>$vo['id']])}" class="btn-link">修改</a>&nbsp;&nbsp;|
                                <a href="javascript:;" class="btn-link" onclick="show('{$vo.LoginUsers.username}');">重置密码</a>&nbsp;&nbsp;|
                        <a onclick="return confirm('正在删除服务商{$vo['name']},删除后将不可恢复\n是否继续删除')" class="btn-link" href="{:url('agents/delagent',['id'=>$vo['id']])}">删除</a>
                        </td>
                        </tr>
                    {/volist}

                    </tbody>
                </table>
                </div>
                {$agentlist->render()}
            </div>
            {include file='public/footer'/}
        </div>

    </section>

    <!-- 是否重置该代理商密码（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

                </div>
                <div class="modal-body"> <h4 class="modal-title" id="myModalLabel">是否重置该代理商密码</h4></div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">否</button>
                    <button type="button" class="btn btn-primary" id="btn-primary" data-id="">是</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

                </div>
                <div class="modal-body" >

                    <div class="form-group" style="    height: 33px;">
                        <label for="password" class="col-sm-2 control-label" style="margin-top: 9px;">账号</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" id="name" name="name" placeholder="请输入账号" value="" disabled>
                        </div>
                        <div class="col-sm-2" style="    margin-top: 5px;">
                            <a href="javascript:;" id="cname" data-clipboard-action="copy"
                               data-clipboard-text=""
                               class="copytext">点击复制</a>
                        </div>
                    </div>
                     <div class="form-group" style="  height: 33px;">
                        <label for="password" class="col-sm-2 control-label" style="margin-top: 9px;">密码</label>
                        <div class="col-sm-8">
                        <input type="text" class="form-control" id="password" name="password" placeholder="请输入密码" value="" disabled>
                        </div>
                         <div class="col-sm-2" style="margin-top: 5px;">
                             <a href="javascript:;" id="cword" data-clipboard-action="copy" data-clipboard-text="" class="copytext">点击复制</a>                         </div>
                    </div>
                    <div class="checkbox">
                        <label><input type="checkbox" value="" name="pname" id="pname">我已保存该账号密码</label>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="btn-default">提交更改</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</body>
    <script>
        function show(name){
            $('#btn-primary').attr("data-id",name);
            $('#myModal').modal('show')
        }
        $("#btn-primary").click(function(){
            $('#myModal').modal('hide')
            $('#myModal1').modal('show')
            var username=$('#btn-primary').attr("data-id");
            $.ajax({
                url: "{:url('agents/resetpassword')}",
                type: 'POST',
                data: {
                    username:username
                },
                success: function (data) {
                    //console.log(data);
                    $('#name').val(data.username);
                    $('#cname').attr("data-clipboard-text",data.username);
                    $('#password').val(data.new_password);
                    $('#cword').attr("data-clipboard-text",data.new_password);
                }
         })
        });
        $("#btn-default").click(function(){
            var aaa = $("#pname").get(0).checked;
           console.log(aaa);
            if(aaa==true){
                $('#myModal1').modal('hide')
            }else if(aaa==false){
                alert("请选中我已保存");
            };




        })

    </script>
    <script src="__STATIC_URL__/static/layer/layer.js"></script>
    <script src="__STATIC_URL__/static/js/clipboard.min.js"></script>
    <script>
        // $(function () {

        var clipboard =  new Clipboard('.copytext');

        clipboard.on('success', function (e) {
            layer.msg('复制成功');
        });

        clipboard.on('error', function (e) {
            layer.msg('复制失败');
        });
        // })
    </script>
    <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
                            function agentform() {
                                $("#agentform").submit();
                            }
</script>
</html>
